package com.by.controller;

import com.by.bean.Goods;
import com.by.remote.GoodsRemoteClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ServivE
 * @version 0.1
 * @className OrderController
 * @description
 * @date 2024/10/28 19:20
 * @since jdk17
 */
@RestController
@RequestMapping("/api")
public class OrderController {

    @Autowired
    GoodsRemoteClient goodsRemoteClient;

    @PostMapping("/order")
    public String save() {
        System.out.println("生成订单");
        //更新库存
        //  String rs = goodsRemoteClient.update(3, 10);
        //  System.out.println("更新结果：" + rs);
        Map map=new HashMap();
        map.put("id",2);
        map.put("num",5);
        String rs=goodsRemoteClient.updateEntity(map);

        //商品详情
        Map ss=goodsRemoteClient.get(3);

        //保存商品
        int result=goodsRemoteClient.save(new Goods(3,6));

        return "success";
    }
}
